<?php
/**
 * Created by PhpStorm.
 * User: xionghao
 * Date: 2017/10/17
 * Time: 15:21
 */

namespace app\meeting\controller;


use app\meeting\model\MeetCategoryModel;
use app\meeting\model\MeetTougaoModel;
use cmf\controller\AdminBaseController;

class AdminTougaoController extends AdminBaseController
{
    public function index($mid)
    {
        $tougaoModel = new MeetTougaoModel();
        $name = $this->request->param('name');
        $start_time = $this->request->param('start_time');
        $end_time = $this->request->param('end_time');
        $where = [];
        if (!empty($name)) {
            $where['title'] = ['like', "%$name%"];
        }
        if (!empty($start_time)) {
            $where['create_time'] = ['>= time', $start_time];
        }
        if (!empty($end_time)) {
            $where['create_time'] = ['< time', $end_time];
        }
        $this->assign('name', $name);
        $this->assign('start_time', $start_time);
        $this->assign('end_time', $end_time);

        $tougaos = $tougaoModel->where($where)->where('mid', $mid)->paginate();
        $this->assign('list', $tougaos);
        $this->assign('page', $tougaos->render());
        return $this->fetch();
    }

    public function detail($id)
    {
        $detail = MeetTougaoModel::get($id);
        $this->assign('detail', $detail);
        return $this->fetch();
    }

}